package AppleCakeMining;

import java.util.ArrayList;


public class Item implements Comparable{
	private int fid;
	private int support;
	private ArrayList<Transaction> appearsIn;
	
	public Item(int id) {
		fid = id;
		support = 0;
		appearsIn = new ArrayList<Transaction>();
	}
	public void addTransaction(Transaction t) {
		appearsIn.add(t);
		support++;		
	}
	
	public int getId() {
		return fid;
	}
	
	public int getSupport() {
		return support;
	}
	
	@Override
	public String toString() {
		return String.valueOf(fid);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Item) {
			Item o = (Item)obj;
			return o.fid == fid;
		}		
		return false;
	}
	
	@Override
	public int hashCode() {
		return fid;
	}
	
	public ArrayList<Transaction> getAppearances() {
		return appearsIn;
	}
	@Override
	public int compareTo(Object obj) {
		if (obj instanceof Item) {
			Item o = (Item)obj;
			if(o.fid > fid) return -1;
			if(o.fid < fid) return 1;
		}
		return 0;
	}
}
